<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 首先要明白队列的特点:First in First out 先进先出,可以说和stack栈的方法很多是反着来的
  class Queue{
    
    constructor(){
      this.item = []
    }
   
    //队列和栈的添加都类似,都是往后面添加一个元素
  enqueue(element){
    this.item.push(element)
  }

   // 队列和栈的删除不一样,队列是在开头删除,因为是先进并拿到那个值
  dequeue(element){
    return this.item.shift()
  }
  
  front(){
    return this.item[0]
  }
 
  isEmpty(){
    return this.item.length ===0?true:false
  }

  size(){
    return this.item.length
  }

  }



  </script>
</body>
</html>